/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package VOs;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Julian
 */
@Entity
@Table(name = "LOCATION")
@NamedQueries({
    @NamedQuery(name = "Location.findAll", query = "SELECT l FROM Location l"),
    @NamedQuery(name = "Location.findById", query = "SELECT l FROM Location l WHERE l.id = :id"),
    @NamedQuery(name = "Location.findByAddress", query = "SELECT l FROM Location l WHERE l.address = :address")})
public class Location implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private BigDecimal id;
    @Column(name = "ADDRESS")
    private String address;
    @JoinColumn(name = "FK_CITY", referencedColumnName = "ID")
    @ManyToOne
    private City fkCity;
    @JoinColumn(name = "FK_ENTERPRISE", referencedColumnName = "ID")
    @ManyToOne
    private Enterprise fkEnterprise;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkLocation")
    private Collection<Reserve> reserveCollection;

    public Location() {
    }

    public Location(BigDecimal id) {
        this.id = id;
    }

    public BigDecimal getId() {
        return id;
    }

    public void setId(BigDecimal id) {
        this.id = id;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public City getFkCity() {
        return fkCity;
    }

    public void setFkCity(City fkCity) {
        this.fkCity = fkCity;
    }

    public Enterprise getFkEnterprise() {
        return fkEnterprise;
    }

    public void setFkEnterprise(Enterprise fkEnterprise) {
        this.fkEnterprise = fkEnterprise;
    }

    public Collection<Reserve> getReserveCollection() {
        return reserveCollection;
    }

    public void setReserveCollection(Collection<Reserve> reserveCollection) {
        this.reserveCollection = reserveCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Location)) {
            return false;
        }
        Location other = (Location) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "VOs.Location[id=" + id + "]";
    }

}
